//
//  ECUSecondHeadCell.m
//  Edu_iOS
//
//  Created by apple on 2017/9/23.
//  Copyright © 2017年 yanyan. All rights reserved.
//

#import "ECUSecondHeadCell.h"

#import "ECUCatalogModel.h"

@interface ECUSecondHeadCell()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UIImageView *circleImageView;
@property (nonatomic, strong) UIView *bottomVerticalLineView;//下竖线
@property (nonatomic, strong) UIView *topVerticalLineView;//上竖线
@property (nonatomic, strong) UIView *horizontalLineView;//横线


@end

@implementation ECUSecondHeadCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initCellUI];
    }
    return self;
}


- (void)initCellUI{
    self.selectionStyle = 0;

    WeakSelf(weakSelf);
    
    _circleImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_circleImageView];
    _circleImageView.image = [UIImage imageNamed:@"catalog_circleShadow"];
    [_circleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(48*KProportion1080_Width);
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.width.height.mas_equalTo(10);
    }];
    
    _topVerticalLineView = [[UIView alloc]init];
    [self.contentView addSubview:_topVerticalLineView];
    _topVerticalLineView.backgroundColor = [UIColor colorWithHexString:@"#DEDFE7"];
    [_topVerticalLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakSelf.circleImageView.mas_centerX);
        make.top.mas_equalTo(weakSelf.contentView.mas_top);
        make.width.mas_equalTo(1);
        make.bottom.mas_equalTo(weakSelf.circleImageView.mas_bottom);
    }];
    
    _bottomVerticalLineView = [[UIView alloc]init];
    [self.contentView addSubview:_bottomVerticalLineView];
    _bottomVerticalLineView.backgroundColor = [UIColor colorWithHexString:@"#DEDFE7"];
    [_bottomVerticalLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakSelf.circleImageView.mas_centerX);
        make.top.mas_equalTo(weakSelf.circleImageView.mas_bottom);
        make.width.mas_equalTo(1);
        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);
    }];
    
    _titleLab = [[UILabel alloc]init];
    [self.contentView addSubview:_titleLab];
    _titleLab.font = [UIFont systemFontOfSize:15];
    _titleLab.textColor = [UIColor colorWithHexString:@"#293039"];
    _titleLab.textAlignment = NSTextAlignmentLeft;
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.circleImageView.mas_right).offset(48.f*KProportion1080_Width);
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.height.mas_equalTo(15);
        make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-10);
    }];
    
    _horizontalLineView = [[UIView alloc]init];
    [self.contentView addSubview:_horizontalLineView];
    _horizontalLineView.backgroundColor = [UIColor colorWithHexString:@"#DEDFE7"];
    [_horizontalLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.titleLab.mas_left);
        make.right.mas_equalTo(weakSelf.contentView.mas_right);
        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    
    _arrowImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_arrowImageView];
    [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-30);
        make.centerY.mas_equalTo(weakSelf.titleLab.mas_centerY);
        make.width.mas_equalTo(36*KProportion1080_Width);
        make.height.mas_equalTo(weakSelf.arrowImageView.mas_width).multipliedBy(20.f/36.f);
    }];
}

//-(void)setDateOfCellWithModel:(ECUCatalogModel *)model{
//    _titleLab.text = model.text;
//    //根据这个属性 判断箭头方向
//    if (model.belowCount == 0) {//折叠
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_downArrow"];
//    }else{
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_upArrow"];
//    }
//
//    //判断上下部竖线是否显示
//    if (model.levelOneWitch == 0) {//判断上部竖线是否显示
//        _topVerticalLineView.hidden = YES;
//        _bottomVerticalLineView.hidden = NO;
//    }else if(model.levelOneCount-1 == model.levelOneWitch){//判断下部的竖线是否显示
//        _topVerticalLineView.hidden = NO;
//        _bottomVerticalLineView.hidden = YES;
//    }else{//上下部横线都显示
//        _topVerticalLineView.hidden = NO;
//        _bottomVerticalLineView.hidden = NO;
//    }
//}
//
//-(void)setBottomLineShowOrHiddenWithModel:(ECUCatalogModel *)model{
//
//    if (model.levelOneCount-1 == model.levelOneWitch) {
//        if (model.belowCount == 0) {//展开方法
//            _topVerticalLineView.hidden = NO;
//            _bottomVerticalLineView.hidden = YES;
//        }else{//收缩方法
//            _topVerticalLineView.hidden = NO;
//            _bottomVerticalLineView.hidden = NO;
//        }
//    }
//}
//
//-(void)setArrowIconImageWithModel:(ECUCatalogModel *)model{
//    //根据这个属性 判断箭头方向
//    if (model.belowCount == 0) {//折叠
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_downArrow"];
//    }else{
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_upArrow"];
//    }
//}



//**********************************************************************************************

-(void)setDateOfCellWithModel:(ECListModel *)model{
    
    if (model.level == 0) {
        self.circleImageView.hidden = YES;
        self.topVerticalLineView.hidden = YES;
        self.bottomVerticalLineView.hidden = YES;
        
        [_titleLab mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_circleImageView.mas_left);
        }];
        
    }else{
        
        
    }
    
    _titleLab.text = model.title;
    //根据这个属性 判断箭头方向
//    if (model.belowCount == 0) {//折叠
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_downArrow"];
//    }else{
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_upArrow"];
//    }
    
    //判断上下部竖线是否显示
//    if (model.levelOneWitch == 0) {//判断上部竖线是否显示
//        _topVerticalLineView.hidden = YES;
//        _bottomVerticalLineView.hidden = NO;
//    }else if(model.levelOneCount-1 == model.levelOneWitch){//判断下部的竖线是否显示
//        _topVerticalLineView.hidden = NO;
//        _bottomVerticalLineView.hidden = YES;
//    }else{//上下部横线都显示
//        _topVerticalLineView.hidden = NO;
//        _bottomVerticalLineView.hidden = NO;
//    }
}

-(void)setBottomLineShowOrHiddenWithModel:(ECListModel *)model{
    
//    if (model.levelOneCount-1 == model.levelOneWitch) {
//        if (model.belowCount == 0) {//展开方法
//            _topVerticalLineView.hidden = NO;
//            _bottomVerticalLineView.hidden = YES;
//        }else{//收缩方法
//            _topVerticalLineView.hidden = NO;
//            _bottomVerticalLineView.hidden = NO;
//        }
//    }
}

-(void)setArrowIconImageWithModel:(ECListModel *)model{
    //根据这个属性 判断箭头方向
//    if (model.belowCount == 0) {//折叠
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_downArrow"];
//    }else{
//        _arrowImageView.image = [UIImage imageNamed:@"catalog_upArrow"];
//    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
